package cn.wbnull.springbootdemo.utils;

import java.io.IOException;
import java.util.List;

import javax.servlet.http.HttpServletResponse;

import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.ExcelWriter;
import com.alibaba.excel.write.metadata.WriteSheet;

import cn.wbnull.springbootdemo.model.Users;

/**
 * 功能描述
 *
 * @author EDZ
 * @since 2022-04-14
 */
public class easyutil {
    public static  void  writerExcel(HttpServletResponse response, List<Users> list) throws IOException {
        ExcelWriter excelWriter = EasyExcel.write(response.getOutputStream()).build();
         //定义工作表对象
          WriteSheet sheet = EasyExcel.writerSheet(0, "sheet").head(Users.class).build();

          //定义第二个工作表的sheet
        WriteSheet sheet2 = EasyExcel.writerSheet(0, "sheet2").head(Users.class).build();
           //往excel文件中写入数据
//            excelWriter.write(list,sheet,sheet2);
            //关闭输出流
            excelWriter.finish();
    }
}
